package com.wntms.ywa.dao;


import com.wntms.ywa.pojo.AddNew;
import com.wntms.ywa.pojo.Details;
import com.wntms.ywa.pojo.FreightContract;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 货运单操作
 */
@Mapper
public interface TmsDao {

    @Insert("insert into freight_contract values(#{fid},#{fare},#{insurancefare},#{auditstatus},#{pay},#{sdate},#{fiid},#{ciid},#{coid},#{flid},#{fsid},#{payment},#{refundtype},#{occurtime})")
    public void add(FreightContract freightContract);
//删除数据
    @Delete("delete from freight_contract where id = #{id}")
    public void deleteById(Integer id);

    @Delete("delete from customer_in where id = #{id}")
    public void deleteCustomerIn(Integer id);
    @Delete("delete from customer_information where id = #{id}")
    public void deleteCustomerInforation(Integer id);
    @Delete("delete from freight_line where id = #{id}")
    public void deleteFreightLine(Integer id);
    @Delete("delete from freight_information where id = #{id}")
    public void deleteFreightInformation(Integer id);
    @Delete("delete from freight_settle where id = #{id}")
    public void deletefse(Integer id);
    @Delete("delete from freight_status where id = #{id}")
    public void deletefss(Integer id);


    @Update("update freight_contract set fare = #{fare}, insurancefare = #{insurancefare}, auditstatus = #{auditstatus}, pay = #{pay} , sdate = #{sdate}, fiid = #{fiid},coid = #{coid}, flid = #{flid}, fsid = #{fsid} where id = #{id}")
    public void update(FreightContract freightContract);
//首页需要的数据 多对1
    @Select("select a.*,b.* from freight_contract as a left JOIN customer_in as b on a.id = b.id ")
    public List<FreightContract> findIndex();

    //详情
    @Select("SELECT a.*,b.*,c.*,d.*,e.* FROM(((freight_contract AS a INNER JOIN customer_in AS b ON a.id = b.id) INNER JOIN freight_information AS c ON a.id = c.id) INNER JOIN customer_information AS d ON a.id = d.id ) INNER JOIN freight_line AS e on a.id = e.id where a.id = #{id}")
    public List<Details> findDetails(Integer id);

    @Select("SELECT * FROM  freight_line where id = #{id}")
    public Details findArrivetime(Integer id);

    //   根据id查找数据
  @Select("select * from freight_contract where id = #{id}")
    public FreightContract findId(Integer id);
//freight_settle  collection_settle
    @Insert("insert into freight_settle (fid,ciid,cid) values(#{fid},#{uid},#{id})")
    public void addfreight_settle(AddNew addNew);
    @Insert("insert into collection_settle (fid,ciid,cid,after_receivables) values(#{fid},#{flid},#{coid},#{after_receivables})")
    public void addC(AddNew addNew);

}
